package com.teamwork.module01.controller;

import com.teamwork.common.entity.module01.Class;
import com.teamwork.common.result.Result;
import com.teamwork.module01.service.ClassService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/mod01/class")
public class ClassController {

    @Resource
    private ClassService classService;

    @GetMapping("/getbyname")
    public Result getByname(String name){
        return classService.getByName(name);
    }
    @GetMapping("/page")
    public Result page(Integer page,Integer size){
        return classService.getPage(page,size);
    }
    @PostMapping
    public Result InsertOrUpdate(@RequestBody Class one){
        return classService.InsertOrUpdate(one);
    }
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id){
        return classService.deleteById(id);
    }
    @DeleteMapping
    public Result batchDelete(List<Integer> ids){
        return classService.batchDelete(ids);
    }

}
